package com.example.bzh.gamecat.ui.message.innerfriend;

import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import com.example.bzh.gamecat.MyApp;

import org.json.JSONObject;

import java.util.logging.Logger;

import cn.jpush.android.api.JPushInterface;

public class NotificationReceiver extends BroadcastReceiver {

    public NotificationReceiver() {
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        //这里存着信息
        Bundle bundle = intent.getExtras();

        if (JPushInterface.ACTION_REGISTRATION_ID.equals(intent.getAction())) {
            Log.d("TAG", "JPush用户注册成功");

        } else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
            Log.d("TAG", "接受到推送下来的自定义消息");

        } else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
            Log.d("TAG", "接受到推送下来的通知");
            MyApp.setFlag(true);
            context.sendBroadcast(new Intent("message"));
            Log.e("TAG", "onReceive: " + MyApp.getFlag());
        } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
            Log.d("TAG", "用户点击打开了通知");
        } else {
            Log.d("TAG", "Unhandled intent - " + intent.getAction());
        }
    }
}
